// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import {routers} from '@/router/index'

import VueRouter from 'vue-router'
import iView from 'iview'
import 'iview/dist/styles/iview.css'
import VueI18n from 'vue-i18n';
import en from 'iview/dist/locale/en-US';
import zh from 'iview/dist/locale/zh-CN';
import ariZh from './lang/zh-ari';
import ariEn from './lang/en-ari';

import '@/element-ui'
import httpRequest from './utils/httpRequest'
import store from './store';
import Echarts from 'echarts'
// import util from './libs/util'
// 配置百度编辑器
import '../static/ueditor/ueditor.config.js'
import '../static/ueditor/ueditor.all.js'
import '../static/ueditor/lang/zh-cn/zh-cn.js'
import '../static/ueditor/ueditor.parse.min.js'

Vue.use(VueI18n);
Vue.use(VueRouter)
Vue.use(iView, {
  i18n: function (path, options) {
    let value = i18n.t(path, options)
    if (value !== null && value !== undefined) {
      return value
    }
    return ''
  }
});

Vue.locale = () => {};

const messages = {
  en: Object.assign(ariEn, en),
  zh: Object.assign(ariZh, zh)
};

let language = 'zh'
if(window.localStorage.language){
  language = window.localStorage.language
}
// Create VueI18n instance with options
const i18n = new VueI18n({
  locale: language,        // set locale
  messages  // set locale messages
});

Vue.prototype.$http = httpRequest

Vue.prototype.$echarts = Echarts

// new Vue({ i18n }).$mount('#app');
// 不启动生产消息
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  i18n,
  router: routers,
  store: store,
  render: h => h(App),
  data: {
    currentPageName: ''
  },
  mounted () {
    // null
    this.currentPageName = this.$route.name;
    // 显示打开的页面的列表
    this.$store.commit('setOpenedList');
    this.$store.commit('initCachepage');
    // 权限菜单过滤相关 主界面需要刷新才会显示菜单-》在登录界面自动刷新页面
    this.$store.commit('updateMenulist');
    // 加载日期格式变化函数
    this.$store.commit("initFormatter")
    // 头像
    // this.$store.commit('setAvator', 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3448484253,3685836170&fm=27&gp=0.jpg');
  }
})
